package com.jinke.uang.model;

import com.jinke.uang.BuildConfig;
import com.jinke.uang.common.UserInfo;
import com.jinke.uang.constant.HttpConstant;
import com.jinke.uang.http.ModelUtils;
import com.jinke.uang.http.ParamsFactory;
import com.jinke.uang.http.RetrofitManager;
import com.jinke.uang.interfaces.ICommonModule;
import com.jinke.uang.interfaces.ICommonView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：Song Shuyu
 * 时间：2019/4/11 19:02
 * package is com.jinke.uang.model
 * 我的页面相关的网络请求
 */
public class MineModule implements ICommonModule{
    @Override
    public void getData(ICommonView view, int apiType,String listType, Object[] t) {
        Map<String, Object> params = new HashMap<>();
        switch (apiType) {

            case HttpConstant.BINDED_CARD_DATA://取银行卡信息接口
                Map<String, Object> map = new HashMap<>();
                map.put("userUuid", UserInfo.getShowUuid());
                List<String> steps = new ArrayList<>();
                steps.add("bank_info_code");
                map.put("pageCodes", steps);
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getBindedCardData(UserInfo.getToken(), ParamsFactory.getCommonParams(map)), view, apiType,listType, t);
                break;

            case HttpConstant.SAVE_BANK_CARD_INFO://添加银行卡接口
                params.clear();
                params.put("userUuid", UserInfo.getSaveUuid());
                params.put("realName", String.valueOf(t[0]));
                params.put("bankCode", String.valueOf(t[1]));
                params.put("bankName", String.valueOf(t[2]));
                params.put("bankCard", String.valueOf(t[3]));
                params.put("authPageCode", "bank_info_code");
                if (UserInfo.isUserInformationWrong()) {
                    params.put("isInformationWrong", 1);
                }
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        saveBankCardInfo(UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.PERSON_INFO://用户信息验证回显接口
                params.put("userUuid", UserInfo.getShowUuid());
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getPersonInfo(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.DICTIONARY_DATA://获取银行卡字典数据
                params.clear();
                params.put("dictType", String.valueOf(t[0]));

                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getDictionaryData(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.UPDATE_BANK_CARD_INFO://更换的银行卡信息接口
                params.clear();
                params.put("realName", String.valueOf(t[0]));
                params.put("bankCode", String.valueOf(t[1]));
                params.put("bankName", String.valueOf(t[2]));
                params.put("bankCard", String.valueOf(t[3]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        updateBankCardInfo(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.HELP_CENTER://帮助中心
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getHelpCenter(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(null)), view, apiType, listType,t);
                break;

            case HttpConstant.REAL_NAME_AUTH_INFO:
                params.clear();
                params.put("userUuid", UserInfo.getShowUuid());
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getRealNameAuthInfo(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.USER_INFO_BACK:  //获取用户回退资料
                params.clear();
                params.put("userUuid", UserInfo.getSaveUuid());
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().
                        getUserInfoBack(UserInfo.getToken(), ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.CALCULATED_ROLL_OVER_DATA: //展期数据计算接口
                params.clear();
                params.put("orderId", String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getCalculatedRollOverData(BuildConfig.channel, UserInfo.getToken(),
                                ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.ORDER_DATA2:
                params.clear();
                params.put("type", String.valueOf(t[0]));
                params.put("limit", String.valueOf(Integer.MAX_VALUE));
                params.put("page", String.valueOf(t[1]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getOrderData2(BuildConfig.channel, UserInfo.getToken(),
                        ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.ORDER_DATA: //根据多个订单类型获取数据
                params.clear();
                params.put("type",String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getOrderData(BuildConfig.channel, UserInfo.getToken(),
                        ParamsFactory.getCommonParams(params)), view, apiType, listType,t);
                break;

            case HttpConstant.OPEN_EXTENSION:  //是否开启展期
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().openExtension
                        (BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(null)), view, apiType, listType,t);
                break;

            default:
                break;
        }
    }
}
